using System;
using Microsoft.Vsa;

namespace SharpVectors.Scripting
{
	/// <summary>
	/// Summary description for VsaScriptEngine.
	/// </summary>
	public abstract class VsaScriptEngine : ScriptEngine, IVsaSite
	{
        #region Fields
        protected IVsaEngine engine;
        protected IVsaItems items;
        #endregion

        #region Constructor
		protected VsaScriptEngine(object scriptGlobal) : base(scriptGlobal) {}
        #endregion

        #region VsaSite interface
        void IVsaSite.GetCompiledState(out Byte[] pe, out Byte[] debugInfo)
        {
            pe = debugInfo = null;
        }

        object IVsaSite.GetEventSourceInstance(string itemName, string eventSourceName)
        {
            return this.scriptGlobal;
        }

        object IVsaSite.GetGlobalInstance(string name)
        {
            object result;

            switch (name) 
            {
                case "window":
                    result = this.scriptGlobal;
                    break;
                default:
                    Console.WriteLine("GlobalInstance not found: " + name);
                    result = null;
                    break;
            }

            return result;
        }

        void IVsaSite.Notify(string notify, object info)
        {
        }

        bool IVsaSite.OnCompilerError(IVsaError e)
        {
            Console.WriteLine(
                String.Format("Error of severity {0} on line {1}: {2}", e.Severity, e.Line, e.Description));

            // Continue to report errors
            return true;
        }
        #endregion
	}
}
